home *** CD-ROM | disk | FTP | other *** search
- ==============================================================================
- QBDATES.DOC Assembler Date Functions for QuickBASIC 02/21/87
- ==============================================================================
-
- Benchmark Software Corp.
- Shelburne, VT
- (802)862-7948
- Jack Stefiuk
-
-
- DATE2INT - Validate & convert a string date to a sequential integer
- INT2DATE - Convert a sequential integer back to a string date
-
- The primary purpose of the above functions is to convert string dates to
- sequential integers and back again. They may also be used to validate or
- determine the day-of-week for a given date. When used together, these two
- functions will allow you to perform any of the following:
-
- * Save disk/RAM space - only 2 bytes/date
- * Easily sort dates using an integer sort
- * Calculate the number of days between dates
- * Determine a 2nd date, a number of days from a 1st date
- * Determine the day-of-week for a given date
- * Check the validity of a date (including leap-years)
- * Determine if the system date has been set
-
- >>>>>>> Refer to DATEDEMO.BAS for specific examples. <<<<<<<
-
- These functions differ from standard date conversions in that 01/01/1980 is used
- as a base (returns 0). Earlier dates return negative numbers and later dates,
- positive numbers. This method provides a very useful range within the confines
- of an integer value:
- -32768 = 04/14/1890 (Earliest)
- -1 = 12/31/1979
- 0 = 01/01/1980
- 1 = 01/02/1980
- 32768 = 09/17/2069 (Latest)
-
- The functions can handle 10 byte "MM/DD/YYYY" or 8 byte "MM/DD/YY" date formats.
- If the latter is used, the functions assume the century to be 1900 and
- consequently, the range is reduced:
-
- -22129 = 01/01/00 (Earliest)
- -1 = 12/31/79
- 0 = 01/01/80
- 1 = 01/02/80
- 7304 = 12/31/99 (Latest)
-
- Both functions return the day-of-week (0-6), where 0=Sunday, etc.
-
- The functions, written in assembly language, have been tested with QuickBASIC
- v2.0 but should work with other compiled BASICs as well. These programs are
- intended for personal use only. No charge may be made for their distribution,
- including "disk fees", etc. This is my way of thanking all the Syops for
- their efforts. I hope you find them useful.
- USING THE FUNCTIONS WITH YOUR PROGRAMS
-
-
- The two functions, INT2DATE & DATE2INT, may be incorporated in your programs
- in any one of three ways. In the following examples, substitute your own
- QuickBASIC application program for DATEDEMO.
-
-
- A. LINKING THE INDIVIDUAL OBJECT FILES
- 1. Create your QuickBASIC program, making the calls as needed.
- 2. Compile your program with either the ".Obj (BCOM.LIB)" or
- ".Obj (BRUN.LIB)" output options.
- 3. Exit QuickBASIC
- 4 Link the object files together with the command :
-
- LINK DATEDEMO+INT2DATE+DATE2INT;
-
-
-
- B. LINKING WITH A LIBRARY FILE
- 1. Create your QuickBASIC program, making the calls as needed.
- 2. Compile your program with either the ".Obj (BCOM.LIB)" or
- ".Obj (BRUN.LIB)" output options.
- 3. Exit QuickBASIC
- 4 Link the object files together with the command :
-
- LINK DATEDEMO,,,QBDATES.LIB;
-
-
-
- C. USING THE QBDATES.EXE FILE (USER LIBRARY)
- 1. Start QuickBASIC with the following command :
-
- QB DATEDEMO /L QBDATES.EXE ( .EXE is REQUIRED !)
-
- 2. Create your QuickBASIC program, making the calls as needed.
- 3. Compile your program with either the "Memory" or "Exe" output
- options.
-
-
-
- All of the files mentioned above are included as part of this package:
-
- DATE2INT.OBJ (Method A)
- INT2DATE.OBJ (Method A)
- QBDATES.LIB (Method B)
- QBDATES.EXE (Method C)
-
- DATEDEMO.BAS (Demo program)
- QBDATES.DOC (This document)
-
-
- SUMMARY
-
- ------------------------------------------------------------------------------
- Function : DATE2INT(DAT$,NUM%,DAY%)
- Arguments: DAT$ - (Passed) String date in either of two forms:
- 01/01/00 thru 12/31/99 ( 8 byte format)
- 04/14/1890 thru 09/17/2069 (10 byte format)
- NUM% - (Returned) Sequential signed integer
- -29219 thru 7304 ( 8 byte format)
- -32768 thru 32767 (10 byte format)
- DAY% - (Returned) Day-of-Week or ERROR code
- -2 = ERROR (DAT$ is invalid length)
- -1 = ERROR (Invalid Date)
- 0 = Sunday
- . . . . . .
- 6 = Saturday
- Purpose : Converts date-string to a sequential signed integer
- Comments : The function automatically determines the length of DAT$.
- If DAT$ is 8 bytes, the century is assumed to be 1900.
- If DAT$ is not exactly 8 or 10 bytes long, DAY% returns -2.
- If DAT$ contains an invalid date, DAY% returns -1.
- ------------------------------------------------------------------------------
- Function : INT2DATE(DAT$,NUM%,DAY%)
- Arguments: DAT$ - (Returned) String date in one of three formats:
- 01/01/00 thru 12/31/99 ( 8 byte format)
- 04/14/1890 thru 09/17/2069 (10 byte format)
- April 14, 1890 thru September 17, 2069 (18 byte format)
- NUM% - (Passed) Sequential signed integer
- -29219 thru 7304 ( 8 byte format)
- -32768 thru 32767 (10 byte format)
- -32768 thru 32767 (18 byte format)
- DAY% - (Returned) Day-of-Week or ERROR code
- -2 = ERROR (DAT$ is invalid length)
- -1 = ERROR (Invalid Date)
- 0 = Sunday
- . . . . . .
- 6 = Saturday
- Purpose : Converts sequential signed integer to a date-string
- Comments : The format of the returned date-string is automatically determined
- by the length of DAT$.
- If DAT$ is 8 bytes, the century is assumed to be 1900.
- If DAT$ is not exactly 8, 10, or 18 bytes long, DAY% returns -2.
- If DAT$ is 8 bytes long and NUM% is out of range, DAY% returns -1.
- ------------------------------------------------------------------------------
-
- NOTES: ZERO's ARE REQUIRED for 8 & 10 byte date-strings !
- The slashes (/), may be replaced with any other character ie (-).
-
- VALID DATES INVALID DATES
- ----------- -------------
- 01/01/1980 01/ 1/1980
- 01/01/80 1/01/80
- 01-01-1980 01011980
- 01 01 80 1/1/80
-